<template>
  <div>
    <van-popup :value="show" position="bottom" @input="$emit('update:show', $event)">
      <div class="van-popup-content">
        <div class="current-rate text-center">
          <span style="color: #787878;margin-right: 5px;">当前</span>
          <span>{{ value }}.00x</span>
        </div>

        <div class="rate-wrap">
          <div class="handle" @click="rate -= 0.1">-</div>
          <div class="rate">{{ rate.toFixed(2) }}</div>
          <div class="handle" @click="rate += 0.1">+</div>
        </div>

        <div class="select-rate">
          <div v-for="(item, index) in rateList" :key="item" :class="rateActive === index && 'active'"
            @click="clickRate(item, index)">
            {{ item }}x
          </div>
        </div>

        <div class="explain">
          <div>
            <span>最大可借</span>
            <span>0 BTC 或 0USDT</span>
          </div>
          <div>
            <span>所需保证金</span>
            <span>0 BTC</span>
          </div>
        </div>

        <van-button class="submit" @click="submit">确认</van-button>

      </div>
    </van-popup>
  </div>
</template>

<script>
import { Popup } from "vant";

export default {
  name: 'Leverage',
  components: {
    [Popup.name]: Popup,
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    value: {}
  },
  data() {
    return {
      active: 1,
      rateList: [1, 2, 3, 5, 10],
      rateActive: 0,
      rate: 1
    }
  },
  methods: {
    clickRate(item, index) {
      this.rateActive = index
      this.rate = item
    },
    submit() {
      this.$emit('update:show', false);
      this.$emit('update:value', this.rate);
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .van-popup {
  // width: 92% !important;
  background: #121212 !important;
  border-radius: 40px 40px 0 0;

  .van-popup-content {
    background: #121212;
    color: #fff;
    position: relative;
    overflow: hidden;
    height: 93vh;
    padding: 90px 30px;
    box-sizing: border-box;

    .rate-wrap {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 80px;

      .handle {
        width: 48px;
        height: 48px;
        background-color: #404040;
        border-radius: 8px;
        font-size: 40px;
        margin: 50px 0;
        line-height: 46px;
        text-align: center;
      }

      .rate {
        font-size: 80px;

        &::after {
          content: "x";
          font-size: 46px;
          margin-left: 5px;
        }
      }
    }

    .select-rate {
      display: flex;
      align-items: center;
      justify-content: center;
      border: 2px solid #1c1c1c;
      border-radius: 99px;
      padding: 5px;

      div {
        height: 52px;
        width: 70px;
        text-align: center;
        line-height: 52px;
        width: 70px;
      }

      .active {
        background-color: #fff;
        border-radius: 99px;
        color: #000;
      }
    }

    .explain {
      background-color: #1A1A1A;
      margin-top: 30px;
      padding: 10px 24px;
      font-size: 24px;
      display: grid;
      gap: 10px;
      border-radius: 8px;

      div {
        display: flex;
        align-items: center;
        justify-content: space-between;

        &>span:first-child {
          color: #929292;
        }
      }
    }

    .submit {
      width: 100%;
      border-radius: 100px;
      color: #000;
      font-weight: bold;
      margin-top: 100px;
    }
  }
}
</style>